package com.hrbxlh.virtualization.dto;

import com.hrbxlh.virtualization.vo.ClusterVO;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.beans.BeanUtils;

/**
 * @author cheer
 */
public class ClusterDTO {

    /**
     * 集群Id
     */
    private Long id;

    /**
     * 集群名称
     */
    private String clusterName;

    /**
     * 主节点镜像名称
     */
    private String masterImageName;

    /**
     * 第一个从节点镜像名称
     */
    private String firstSlaveImageName;

    /**
     * 第二个从节点镜像名称
     */
    private String secondSlaveImageName;

    /**
     * 创建人
     */
    private String username;

    public ClusterVO convertToClusterVO() {
        ClusterVO clusterVO = new ClusterVO();
        BeanUtils.copyProperties(this, clusterVO);
        clusterVO.setName(clusterName);
        if (clusterVO.getMasterImageName() == null) {
            clusterVO.setMasterImageName("已删除");
        }
        if (clusterVO.getFirstSlaveImageName() == null) {
            clusterVO.setFirstSlaveImageName("已删除");
        }
        if (clusterVO.getSecondSlaveImageName() == null) {
            clusterVO.setSecondSlaveImageName("已删除");
        }
        return clusterVO;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getClusterName() {
        return clusterName;
    }

    public void setClusterName(String clusterName) {
        this.clusterName = clusterName;
    }

    public String getMasterImageName() {
        return masterImageName;
    }

    public void setMasterImageName(String masterImageName) {
        this.masterImageName = masterImageName;
    }

    public String getFirstSlaveImageName() {
        return firstSlaveImageName;
    }

    public void setFirstSlaveImageName(String firstSlaveImageName) {
        this.firstSlaveImageName = firstSlaveImageName;
    }

    public String getSecondSlaveImageName() {
        return secondSlaveImageName;
    }

    public void setSecondSlaveImageName(String secondSlaveImageName) {
        this.secondSlaveImageName = secondSlaveImageName;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("id", id)
                .append("clusterName", clusterName)
                .append("masterImageName", masterImageName)
                .append("firstSlaveImageName", firstSlaveImageName)
                .append("secondSlaveImageName", secondSlaveImageName)
                .append("username", username)
                .toString();
    }
}
